<?php include $this->getViewFile('/common/Head') ?>
<body class="J_scroll_fixed">
<style>
.col-left{float:left}
.col-auto{overflow:hidden;_zoom:1;_float:left;}
.title-1{border-bottom:1px solid #eee; padding-left:5px}
.f14{font-size: 14px}
.lh28{line-height: 28px}
.blue,.blue a{color:#004499}
.gray4,a.gray4{color:#999;}
.lh22{line-height: 22px}
.lh25{line-height: 25px}
</style>
<div class="wrap J_check_wrap">
  <?php include $this->getViewFile('/common/Nav') ?>
  <div class="h_a">查找</div>

<?php $objForm = $this->beginWidget( 'CActiveForm', array('id' => 'searchForm','method' => 'get', 'action' => $this->createUrl('index'))); ?>
    <div class="search_type cc mb10">
      <div class="mb10"> 
      <?php echo $model->getAttributeLabel('status') ?>：
      <?php  echo $objForm->dropDownList($model,'status',RedeemModel::getStatusHtmlList(),array('empty' => '全部'));  ?>

      <?php echo $model->getAttributeLabel('pay_status') ?>：
      <?php  echo $objForm->dropDownList($model,'pay_status',RedeemModel::getPayStatusHtmlList(),array('empty' => '全部'));  ?>



        时间范围：
        <input type="text" name="RedeemModel[start_time]" class="input length_2 J_date" value="<?php echo $model->start_time?>" placeholder="选择起始时间">

        -

        <input type="text" name="RedeemModel[end_time]" class="input length_2 J_date" value="<?php echo $model->end_time?>" placeholder="选择结束时间">
	</div>


       <div class="mb10">
        关键字：<?php echo Form::select(array(1=>'商品标题', 2=>'产品ID', 3=>'会员ID'),$type,'name="type"') ?>
        <input type="text" class="input length_2" name="keyword" style="width:200px;" value="<?php echo $keyword?>" placeholder="请输入搜索内容...">
        <button class="btn">搜索</button>
      </div>


    </div>
<?php $this->endWidget(); ?>


  <div class="mb10"> 共有 ( <b><?php echo $count; ?></b> ) 个宝贝</div>
  <form name="myform" action="" method="post" class="J_ajaxForm">
    <div class="table_list">
      <table width="100%" cellspacing="0">
        <thead>
          <tr>
            <td width="50" align="center"><input type="checkbox" class="J_check_all" data-direction="x" data-checklist="J_check_x">全选</td>
            <td align="center">兑换商品信息</td>
            <td width="100" align="center">商品状态</td>
            <td width="200" align="center">管理操作</td>
          </tr>
        </thead>
        <tbody>
         <?php
		 foreach($data as $rs){
		 ?>
         <tr  id="gbinfo_<?php echo $rs->id;?>">
            <?php include $this->getViewFile('public_load'); ?>
         </tr>
         <?php
		 }
		 ?>
        </tbody>
      </table>
      <div class="p10">
        <div class="pages"><?php echo $Page;?></div>
      </div>
    </div>
  </form>
</div>
<script src="<?php echo $staticUrl; ?>statics/js/common.js"></script>
<script>
//加载信息
function loads(id){
	$.get('<?php echo AdminBase::U("public_load") ?>',{id:id},function(data){
		if(data != ''){
			$("#gbinfo_"+id).html(data);
			changes();
		}
	});
}
//保存
function saveData(data, obj){
	Wind.use("artDialog", "iframeTools", function () {
		$.post('<?php echo AdminBase::U("edit") ?>',data,function(rs){
			if(rs.status){
				art.dialog.tips('修改成功！', 1.5);
				$(obj).data('value',$(obj).val());
			}else{
				art.dialog.tips(rs.info, 3);
				$(obj).val($(obj).data('value'));
			}
			//重新加载
			//loads(data.id);
		},'json');
	});
}
//绑定修改事件
function changes(){

	//$('.table_list')



	//标题修改
	$('input[data-id],select[data-id]').change(function(){
		var id = $(this).data('id');
		var value = $(this).val();
		var title = $(this).attr('name');
		if(value != '' && id > 0){
			var data = {};
			data.id = id;
			data[title] = value;
			saveData(data, this);
			return true;
		}
		return false;
	});
}

function addFormValue()
{
	var objs = $('input[data-id],select[data-id]');
	var length = objs.length;
	for(var i=0;i<length;i++)
	{
	  var obj = objs.eq(i);
	  var value = obj.val();
	  obj.data('value',value);
	}    
}

$(function(){
	addFormValue();
	changes();

});
</script>
</body>
</html>